package com.bicycle.rentalsystem.servelt.user;


import com.bicycle.rentalsystem.pojo.user.UserMessage;
import com.bicycle.rentalsystem.service.impl.user.UserMessageServiceImpl;
import com.bicycle.rentalsystem.service.user.UserMessageService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/user/informational")
public class informationalServlet extends HttpServlet {

    private UserMessageService userMessageService = new UserMessageServiceImpl();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String qianming = req.getParameter("qianming");
        String sex = req.getParameter("sex");
        String telephone = req.getParameter("telephone");
        String username = req.getParameter("username");
        int returnMessage = userMessageService.returnMessage(username);
        UserMessage message = userMessageService.getMessage(username);
        HttpSession session = req.getSession();
        session.setAttribute("user",message);
        if (returnMessage == 1){
            resp.sendRedirect("user");
        }

    }
}
